<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class Sign extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sign';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        for ($i = 1; $i <= 10; $i++) {


            $this->sign($i);
            sleep(10);


        }
    }

    public function sign($i)
    {


        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => 'https://home.hpzyh.com/api/user/sign',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => '{"token":"MDAwMDAwMDAwMIKio2eBereZ"}',
            CURLOPT_HTTPHEADER => array(
                'Host:  home.hpzyh.com',
                'Connection:  keep-alive',
                'Content-Length:  36',
                'APP:  sanlinggo',
                'Cookie:  JSESSIONID=Wa07356f2dfe180b0697d0f9e2c79ee0b; acw_tc=76b20f6716494952465067558e520b7eae4f020a1de2ad36e90ff3aad7d7dd',
                'User-Agent:  Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat',
                'content-type:  application/json',
                'Referer:  https://servicewechat.com/wx24ad361ca12ccde2/2/page-frame.html',
                'Accept-Encoding:  gzip, deflate, br'
            ),
        ));
        $response = curl_exec($curl);
        curl_close($curl);
        $this->line($i + 1 . 'success----');

    }
}
